Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2etest: adding and cleaning aws disk #188

Merged
merged 1 commit into from
May 27, 2022

Conversation

riya-singhal31
Copy link
Contributor

@riya-singhal31 riya-singhal31 commented May 11, 2022

adds aws disk in the test namespace for resources to get installed.

Signed-off-by: riya-singhal31 rsinghal@redhat.com

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 11, 2022
@riya-singhal31 riya-singhal31 force-pushed the aws-disk branch 3 times, most recently from 4ac3307 to 699c483 Compare May 12, 2022 07:48
@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 12, 2022
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 12, 2022
@riya-singhal31 riya-singhal31 force-pushed the aws-disk branch 2 times, most recently from 7effd2f to 50aa67d Compare May 12, 2022 08:08
@riya-singhal31 riya-singhal31 changed the title [WIP]e2etest: adding and cleaning aws disk e2etest: adding and cleaning aws disk May 19, 2022
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 19, 2022
@riya-singhal31
Copy link
Contributor Author

/test lvm-operator-bundle-e2e-aws

@riya-singhal31 riya-singhal31 requested a review from sp98 May 19, 2022 05:11
Copy link
Contributor

@sp98 sp98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some minor comments. Overall looks good. Need to wait for the CI to pass though.
Mostly the review comments are around the disk count. Also, there are some linting errors that should be fixed.

}

/*
// represents the disk layout to setup on the nodes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this commented code is not needed. You can remove this.

e2e/aws_disk.go Outdated

func createAndAttachAWSVolumesForNode(t *testing.T, nodeEntry nodeDisks, ec2Client *ec2.EC2) {
node := nodeEntry.node
if len(nodeEntry.disks) > 20 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nodeEntry.disks count is not a user input and is something that we are setting in the code. So it always be fixed.
So I think there is no need for this check.

e2e/aws_disk.go Outdated
t.Fatalf("failed to create and attach aws disks for node %q: %+v", nodeEntry.node.Name, err)
}
volumes := make([]*ec2.Volume, len(nodeEntry.disks))
volumeLetters := []string{"g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need all these volume letters? I would keep it same as the disk count that we are using.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kept 2 letters now, as we are creating 2 disks.

)

func diskSetup() func(*testing.T) {
return func(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this need to be a function inside another function ? For simplicity, I would prefer to keep it a single function if internal function is not needed here.

}

func diskRemoval() func(*testing.T) {
return func(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this need to be a function inside another function ? For simplicity, I would prefer to keep it a single function if internal function is not needed here.

@riya-singhal31
Copy link
Contributor Author

riya-singhal31 commented May 19, 2022

Added some minor comments. Overall looks good. Need to wait for the CI to pass though. Mostly the review comments are around the disk count. Also, there are some linting errors that should be fixed.

Thanks for the suggestions Santosh.
Updated the PR.

@riya-singhal31 riya-singhal31 force-pushed the aws-disk branch 2 times, most recently from d55c34a to 3727440 Compare May 19, 2022 14:47
"sigs.k8s.io/controller-runtime/pkg/client"
)

func diskSetup(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need a testing.T argument here? It does not match the way the other functions have been written.
Please try to do this without testing.T

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

e2e/aws_disk.go Outdated
volumeIDs := make([]*string, 0)
instanceID, _, zone, err := getAWSNodeInfo(node)
if err != nil {
t.Errorf("failed to create and attach aws disks for node %q: %+v", nodeEntry.node.Name, err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will cause the tests to fail when run against our baremetal clusters.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When would we want to run the e2e tests on baremetal clusters?
Only for testing locally on SNO?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the e2e-tests are meant to be run against local clusters when required as well.

Copy link
Contributor

@nbalacha nbalacha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide a way to skip the AWS disk setup and delete using command line glags or env variables. This is ensure that the tests do not fail when run against a non-aws cluster.
https://onsi.github.io/ginkgo/#supporting-custom-suite-configuration


// represents the disk layout to setup on the nodes.
var nodeEnv []nodeDisks
for _, disks := range nodeList.Items {
Copy link
Contributor

@nbalacha nbalacha May 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the node being referred to by a variable called disk?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This overwrites the entries so only a single node will have disks attached.

Copy link
Contributor

@nbalacha nbalacha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Errors should be returned and checked wherever required.

Makefile Outdated
@@ -315,10 +315,12 @@ lvm-must-gather:
# Variables required to run and build LVM end to end tests.
LVM_OPERATOR_INSTALL ?= true
LVM_OPERATOR_UNINSTALL ?= true
DISK_INSTALL ?= false
DISK_UNINSTALL ?= false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not required - if the disk is created, it should be removed.

e2e/aws_disk.go Outdated
volumeIDs := make([]*string, 0)
instanceID, _, zone, err := getAWSNodeInfo(node)
if err != nil {
fmt.Printf("failed to create and attach aws disks for node %q: %+v\n", nodeEntry.node.Name, err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function should return here.

e2e/aws_disk.go Outdated
}
}

func createAndAttachAWSVolumesForNode(nodeEntry nodeDisks, ec2Client *ec2.EC2) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function should return an error.

e2e/aws_disk.go Outdated
volume, err := ec2Client.CreateVolume(createInput)
if err != nil {
err := fmt.Errorf("expect to create AWS volume with input %v: %w", createInput, err)
fmt.Printf("failed to create and attach aws disks for node %q: %+v\n", nodeEntry.node.Name, err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return on failure. This comment holds for all other errors in the function.

e2e/config.go Outdated
@@ -33,6 +39,8 @@ func init() {
flag.StringVar(&LvmSubscriptionChannel, "lvm-subscription-channel", "", "The subscription channel to revise updates from")
flag.BoolVar(&lvmOperatorInstall, "lvm-operator-install", true, "Install the LVM operator before starting tests")
flag.BoolVar(&lvmOperatorUninstall, "lvm-operator-uninstall", true, "Uninstall the LVM cluster and operator after test completion")
flag.BoolVar(&DiskInstall, "disk-install", false, "Do not install disks unless specified")
flag.BoolVar(&DiskUninstall, "disk-uninstall", false, "Do not uninstall disks unless specified")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not required.

e2e/disk_setup.go Show resolved Hide resolved

// represents the disk layout to setup on the nodes.
var nodeEnv []nodeDisks
for _, disks := range nodeList.Items {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename the variable disks. The entry being referred to in the loop is a node.

Makefile Outdated
@@ -315,10 +315,12 @@ lvm-must-gather:
# Variables required to run and build LVM end to end tests.
LVM_OPERATOR_INSTALL ?= true
LVM_OPERATOR_UNINSTALL ?= true
DISK_INSTALL ?= false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment that this only handles AWS for now.

e2e/aws_disk.go Outdated
}

const (
awsPurposeTag = "lvm-e2etest"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
awsPurposeTag = "lvm-e2etest"
awsPurposeTag = odf-lvmo"


// BeforeTestSuiteSetup is the function called to initialize the test environment.
func BeforeTestSuiteSetup() {

if DiskInstall {
debug("Creating disk for CI\n")
diskSetup()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should return an error val which should be checked.

@riya-singhal31
Copy link
Contributor Author

/test lvm-operator-bundle-e2e-aws

@riya-singhal31 riya-singhal31 changed the title e2etest: adding and cleaning aws disk [WIP]e2etest: adding and cleaning aws disk May 25, 2022
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 25, 2022
Makefile Outdated
@@ -317,8 +317,11 @@ LVM_OPERATOR_INSTALL ?= true
LVM_OPERATOR_UNINSTALL ?= true
SUBSCRIPTION_CHANNEL ?= alpha

# Handles only AWS as of now.
DISK_INSTALL ?= true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set this to false by default after confirming that the CI passes with it set to true.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I did that for checking purpose only.

e2e/aws_disk.go Outdated
// this function is async
func createAndAttachAWSVolumes(ec2Client *ec2.EC2, namespace string, nodeEnv []nodeDisks) {
for _, nodeEntry := range nodeEnv {
go createAndAttachAWSVolumesForNode(nodeEntry, ec2Client)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There needs to be a way to return an error to the calling function. You can skip the goroutine and do this serially for now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An additional problem here is that the disks may not have been created or attached before the LVMO is deployed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'll do it serially.
That's right because PVC test is getting passed. Problem is that TopoLVM node pod is not ready, so its failing lvm cluster reconciliation test here.


// BeforeTestSuiteSetup is the function called to initialize the test environment.
func BeforeTestSuiteSetup() {

if DiskInstall {
debug("Creating disk for CI\n")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
debug("Creating disk for CI\n")
debug("Creating disks for e2e tests\n")

err = cleanupAWSDisks(ec2Client)
gomega.Expect(err).To(gomega.BeNil())

return nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return nil
return err


// represents the disk layout to setup on the nodes.
var nodeEnv []nodeDisks
for _, nodes := range nodeList.Items {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for _, nodes := range nodeList.Items {
for _, node := range nodeList.Items {

@riya-singhal31 riya-singhal31 force-pushed the aws-disk branch 2 times, most recently from dad4b48 to bbb018a Compare May 26, 2022 05:56
@riya-singhal31
Copy link
Contributor Author

/retest

1 similar comment
@riya-singhal31
Copy link
Contributor Author

/retest

@riya-singhal31 riya-singhal31 changed the title [WIP]e2etest: adding and cleaning aws disk e2etest: adding and cleaning aws disk May 26, 2022
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 26, 2022
e2e/config.go Outdated
@@ -33,6 +36,7 @@ func init() {
flag.StringVar(&LvmSubscriptionChannel, "lvm-subscription-channel", "", "The subscription channel to revise updates from")
flag.BoolVar(&lvmOperatorInstall, "lvm-operator-install", true, "Install the LVM operator before starting tests")
flag.BoolVar(&lvmOperatorUninstall, "lvm-operator-uninstall", true, "Uninstall the LVM cluster and operator after test completion")
flag.BoolVar(&DiskInstall, "disk-install", true, "Do not install disks unless specified")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
flag.BoolVar(&DiskInstall, "disk-install", true, "Do not install disks unless specified")
flag.BoolVar(&DiskInstall, "disk-install", true, "Create and attach disks to the nodes. This currently only works with AWS")

@@ -44,4 +52,10 @@ func AfterTestSuiteCleanup() {
err = DeployManagerObj.UninstallLVM(LvmCatalogSourceImage, LvmSubscriptionChannel)
gomega.Expect(err).To(gomega.BeNil(), "error uninstalling LVM: %v", err)
Copy link
Contributor

@nbalacha nbalacha May 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
gomega.Expect(err).To(gomega.BeNil(), "error uninstalling LVM: %v", err)
gomega.Expect(err).To(gomega.BeNil(), "error uninstalling the LVM Operator: %v", err)

}
return ds.Status.DesiredNumberScheduled == ds.Status.NumberReady
}, timeout, interval).Should(BeTrue())
debug("Status is ready\n")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
debug("Status is ready\n")
debug("TopolvmNode Status is ready\n")

@riya-singhal31
Copy link
Contributor Author

/retest

e2e/aws_disk.go Outdated
// do not provide more than 20 disksize
// do not use more than once per node
// this function is async
func createAndAttachAWSVolumes(ec2Client *ec2.EC2, namespace string, nodeEnv []nodeDisks) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the namespace is not required and can be removed.

)

func diskSetup() error {
namespace := TestNamespace
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the namespace var is not used and can be removed.

Comment on lines 25 to 26
gomega.SetDefaultEventuallyTimeout(time.Minute * 10)
gomega.SetDefaultEventuallyPollingInterval(time.Second * 2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this being used?

adds aws disk in the test namespace for resources to get installed.

Signed-off-by: riya-singhal31 <rsinghal@redhat.com>
@riya-singhal31
Copy link
Contributor Author

riya-singhal31 commented May 27, 2022

Thanks @nbalacha for all the optimization suggestions and corrections.
Updated the PR.

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label May 27, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented May 27, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: nbalacha, riya-singhal31

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 27, 2022
@openshift-merge-robot openshift-merge-robot merged commit 192622d into openshift:main May 27, 2022
@iamniting
Copy link
Member

This PR also updates prometheus/client_golang which is required to be backported for https://bugzilla.redhat.com/show_bug.cgi?id=2056104

/cherry-pick release-4.11

@openshift-cherrypick-robot

@iamniting: new pull request created: #209

In response to this:

This PR also updates prometheus/client_golang which is required to be backported for https://bugzilla.redhat.com/show_bug.cgi?id=2056104

/cherry-pick release-4.11

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants